using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

//Importamos
using EventSys.BussinesEntities;

namespace EventSys.Repository.Mapping

{
    public class DetAuspiciadorMap : EntityTypeConfiguration<DetAuspiciador>
    {
        public DetAuspiciadorMap()
        {
            // Primary Key
            this.HasKey(t => new { t.idDetAuspiciador, t.idEvento });

            // Properties
            this.Property(t => t.idDetAuspiciador)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.idEvento)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("DetAuspiciador");
            this.Property(t => t.idDetAuspiciador).HasColumnName("idDetAuspiciador");
            this.Property(t => t.idEvento).HasColumnName("idEvento");
            this.Property(t => t.idAuspiciador).HasColumnName("idAuspiciador");

            // Relationships
            this.HasRequired(t => t.Auspiciador)
                .WithMany(t => t.DetAuspiciadors)
                .HasForeignKey(d => d.idAuspiciador);
            this.HasRequired(t => t.Evento)
                .WithMany(t => t.DetAuspiciadors)
                .HasForeignKey(d => d.idEvento);

        }
    }
}
